package com.qf.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Arrays;
import java.util.Date;

public class User {
    //Json转换的时候忽略这个字段
    @JsonIgnore
    private Integer id;
    private String name;
    //性别
    //Json转换的时候，给key值改名字
//    @JsonProperty("sex")
    private Boolean gender;
    //出生日期
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    //json转换时的日期格式化
//    @JsonFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern ="yyyy-MM-dd")
    private Date birthday;
    //爱好==数组类型
    //如果这个字段的值为null，自动忽略掉，不参与json转换。
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String[] hoppy;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Boolean getGender() {
        return gender;
    }

    public void setGender(Boolean gender) {
        this.gender = gender;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public String[] getHoppy() {
        return hoppy;
    }

    public void setHoppy(String[] hoppy) {
        this.hoppy = hoppy;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", gender=" + gender +
                ", birthday=" + birthday +
                ", hoppy=" + Arrays.toString(hoppy) +
                '}';
    }
}
